#include <linux/module.h>
#include <linux/interrupt.h>

#define MOUSE_IRQ_NUM	12

static int irq_cnt = 0;

static irqreturn_t irq_test_handler(int irq_no, void *dev)
{
	int *count;

	count = (int *)dev;
	(*count)++;

	printk("IRQ number: %d, triggered time: %d\n", irq_no, *count);

	return IRQ_HANDLED;
}

static int __init irq_test_init(void)
{
	int ret;

	ret = request_irq(MOUSE_IRQ_NUM, irq_test_handler, IRQF_SHARED, "irq_test", (void *)&irq_cnt);
	if (ret != 0) {
		printk("Request irq: %d failed.\n", MOUSE_IRQ_NUM);
	}

	printk("%s Done.\n", __FUNCTION__);

	return 0;
}

static void __exit irq_test_exit(void)
{
	free_irq(MOUSE_IRQ_NUM, (void *)&irq_cnt);

	printk("%s Done.\n", __FUNCTION__);
}

module_init(irq_test_init);
module_exit(irq_test_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("YYW");
